package com.example.surveyapplication;

import help.Utility;

import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Menu;
import dao.DatabaseHelper;

public class IntroActivity extends Activity {
	private Timer timer;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_intro);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
		
		DatabaseHelper helper = new DatabaseHelper(this);
		try {
			helper.checkAndCopyDatabase();
			Utility.init();
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		this.timer = new Timer();
		timer.schedule(new TimerTask() {          
	        @Override
	        public void run() {
	            navigateToLoginActivity();
	        }

	    }, 2000);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.intro, menu);
		return true;
	}

	private void navigateToLoginActivity() {
		Intent intent = new Intent(this, SignInActivity.class);
		startActivity(intent);
	}
}
